package com.top.mall.main.access

import androidx.lifecycle.Observer
import com.module.lemlin.owner.OwnerViewModeFragment
import com.top.mall.R
import com.top.mall.jetpack.vm.AccessViewModel
import kotlinx.android.synthetic.main.fragment_access_login_check.*

class AccessLoginCheckFragment : OwnerViewModeFragment<AccessViewModel>() {

    companion object {
        fun newInstance(): AccessLoginCheckFragment {
            return AccessLoginCheckFragment()
        }
    }

    override val layoutResId: Int
        get() = R.layout.fragment_access_login_check

    override fun viewModel(): AccessViewModel {
        return createViewModel()
    }

    override fun initData() {
        viewModel.observableLoginCheck(edit_login_check_phone)
    }

    override fun initViewMode() {
        viewModel.isEnabledLoginCheckLiveData.observe(viewLifecycleOwner, Observer { isEnabled ->
            isEnabled?.let {
                text_login_check_get_captcha.isEnabled = it
            }
        })
    }

    override fun onDestroyView() {
        super.onDestroyView()
        viewModel.clearLiveDataLoginCheck()
    }
}